package com.itheima.service.impl;

import com.itheima.mapper.ClazzOptionMapper;
import com.itheima.pojo.ClazzOption;
import com.itheima.service.ClazzOptionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class ClazzOptionServiceImpl implements ClazzOptionService {

    @Autowired
    private ClazzOptionMapper clazzOptionMapper;

    @Override
    public ClazzOption getClazzCountData() {
        List<Map<String, Object>> list = clazzOptionMapper.getClazzCountData();
        List<Object> pom = list.stream().map(m -> m.get("pom")).toList();
        List<Object> total = list.stream().map(m -> m.get("total")).toList();
        ClazzOption clazzOption = new ClazzOption(pom, total);
        return clazzOption;
    }

    @Override
    public List<Map> getStudentDegreeCount() {
        List<Map> list = clazzOptionMapper.getStudentDegreeCount();
        return list;
    }
}
